package com.itheima.framework.view;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @program: Implementing springmvc
 * @description:
 * @author: zhanghz001
 * @create: 2020-12-05 11:15
 **/
public class ViewAdapter implements View {
    private PrintViewHandler printViewHandler = new PrintViewHandler();
    private ForwardViewHandler forwardViewHandler = new ForwardViewHandler();

    @Override
    public void render(HttpServletRequest request,
                       HttpServletResponse resp,
                       Object result) {
        //view
        //包装返回
        if (result instanceof String) {
            forwardViewHandler.forward(request, resp, result);
        } else {
            printViewHandler.print(request, resp, result);

        }

    }
}
